﻿<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <script>
        /*
           *****
           ****
           ***
           **
           *
           思路：双重for 循环，外层控制行，内层控制列
           i       num 的最大值
           0           5
           1           4
           2           3
           3           2
           4           1
           
           i + num = 5
           num = 5 - i;
       */
        for (var i = 0; i < 5; i++) {
            let star = '';
            for (var j = 0; j < 5 - i; j++) {
                star = star + '*';
            }
            console.log(star);
        }
        for (var i = 5; i > 0; i--) {
            let star = '';
            for (var j = 0; j < 6 - i; j++) {
                star = star + '*';
            }
            console.log(star);
        }
        for (var i = 4; i >=0; i--) {
            let star = '';
            for (var k = 0; k < i; k++) {
                star = star + ' ';
            }
            for (var j = 0; j < 5- i; j++) {
                star = star +'*';
            }
            console.log(star);
        }
    </script>
    
</body>
</html>